#ifndef AZRECORDDATA_H
#define AZRECORDDATA_H

#include <QVariant>
#include <QVector>

#include "Az.h"
#include "AzField.h"

//class AzFieldList;

class AzRecordValues: public QVector <QVariant>  {
public:
    inline AzRecordValues() {}
    inline AzRecordValues(const AzFieldList& src)                   { *this = src.fieldsType();}
    inline AzRecordValues(int size): QVector <QVariant>(size)       {}
    ~AzRecordValues() {}
    inline AzRecordValues& operator = (const AzFieldList& src)
    { *this = src.fieldsType(); return *this; }
};


class AzRecordData {
public:
    AzRecordData(Az::RecordState = Az::Unmodified);
    AzRecordData(const AzFieldList&);
    AzRecordData(const AzRecordData&);
    ~AzRecordData() {}

    void insert(int,QVariant::Type);
    void remove(int);
    void replace(int,QVariant::Type);


    inline const AzRecordValues& data() const             { return mData; }
    inline const AzRecordValues& oldData() const          { return mOldData; }

    inline QVariant data(int i) const                       { return mData[i]; }
    inline QVariant oldData(int i) const                    { return mOldData[i]; }

    inline int size() const                                 { return mData.size(); }
    inline QVariant::Type type(int i) const                 { return mData[i].type(); }

    inline void setData(int i, const QVariant& val)         { mData[i] = val;       }
    inline void setData(const AzRecordValues& data)       { mData = data; }
    inline void setOldData(const AzRecordValues& data)    { mOldData = data; }

    inline Az::RecordState recordState() const              { return mRecordState; }
    inline void setRecordState(const Az::RecordState state) { mRecordState = state; }

    bool operator==(const AzFieldList&) const;
    inline bool operator!=(const AzFieldList& fields) const { return !operator==(fields); }

private:
    AzRecordValues mData, mOldData;
    Az::RecordState mRecordState;
};


#endif // AZRECORDDATA_H
